using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

namespace Tools.UI
{
    [AddComponentMenu("Tools/UI/OnPointerUpEvent")]
    public class OnPointerUpEvent : MonoBehaviour, IPointerDownHandler,IPointerUpHandler
    {
        [SerializeField] UnityEvent<PointerEventData> onPointerUpEvent;
        [SerializeField] UnityEvent<PointerEventData> onPointerDownEvent;
        public UnityEvent<PointerEventData> PointerUpEvent => onPointerUpEvent;
        public UnityEvent<PointerEventData> PointerDownEvent => onPointerDownEvent;
        
        void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
        {
            Debug.Log($"{name} OnPoint Up");
            onPointerUpEvent?.Invoke(eventData);
        }

        void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
        {
            onPointerDownEvent?.Invoke(eventData);
        }
    }
}
